package com.qjc;

import java.util.ArrayList;
import java.util.List;

/**
 * 文件描述
 *
 * @ClassName: QjcSolution
 * @Author: qjc
 * @Date: 2022/7/20 14:49
 */
public class QjcSolution {

    public static void main(String[] args) {
        List<int[]> resultList = new ArrayList<>();
        int[] arr = {1, 2, 7};
        permutation(resultList, arr, 0);
        for (int[] allSort : resultList) {
            for (int i : allSort) {
                System.out.print(i);
            }
            System.out.println();
        }
    }

    public static void permutation(List<int[]> resultList, int[] arr, int begin) {
        if (begin == arr.length - 1) {
            int[] newArr = new int[arr.length];
            for (int i = 0; i < arr.length; i++) {
                newArr[i] = arr[i];
            }
            resultList.add(newArr);
        } else {
            for (int i = begin; i < arr.length; i++) {
                // 交换
                int temp = arr[begin];
                arr[begin] = arr[i];
                arr[i] = temp;
                // 递归调用
                permutation(resultList, arr, begin + 1);
                // 归位
                arr[i] = arr[begin];
                arr[begin] = temp;
            }
        }
    }


}
